package com.syg.logback.util;

import org.slf4j.MDC;

/**
 * @author syg
 * @version 1.0
 * @date 2021年11月23日15:54:46
 */
public class TraceUtil {

    public static final String SYG_TRACE_ID = "SYG_TRACE_ID";
    public static final String LOCAL_TRANCE_ID = "LOCAL-TRACE-ID";
    public static final String LOCAL_SPAN_ID = "LOCAL-SPAN-ID";
    public static final String LOCAL_SPAN_PARENT_ID = "LOCAL-SPAN-PARENT-ID";
    public static final String TRACE_LEVEL = "traceLevel";
    public static final String APPLICATION_NAME = "applicationName";
    public static final String SERVER_ENV = "serverEnv";

    public TraceUtil() {
    }

    public static String getSygTraceKeyName() {
        return "SYG_TRACE_ID";
    }

    public static String getLocalTraceKeyName() {
        return "LOCAL-TRACE-ID";
    }

    public static String getApplicationNameName() {
        return "applicationName";
    }

    public static String getServerEnvName() {
        return "serverEnv";
    }

    public static String getTraceLevelName() {
        return "traceLevel";
    }

    public static void begin(String key, String value) {
        // MDC.put(key, value);
    }

    public static void beginTrace(String sygTraceId, String localTraceId) {
        beginZycfcTrace(sygTraceId);
        beginLocalTrace(localTraceId);
    }


    public static void beginZycfcTrace(String sygTraceId) {
        // MDC.put("SYG-TRACE-ID", sygTraceId);
    }

    public static void beginLocalTrace(String localTraceId) {
        // MDC.put("LOCAL-TRACE-ID", localTraceId);
    }

    public static void beginApplicationNameAndEnv(String applicationName, String serverEnv) {
        MDC.put("applicationName", applicationName);
        MDC.put("serverEnv", serverEnv);
    }
}
